*{
    margin: 0;
    padding: 0;
}

body{
    background: #2c3e50;
}
nav{
    position: relative;
    margin: 270px auto 0;
    width: 500px;
    height: 50px;
    background: #34495e;
    border-radius: 8px;
    font-size: 0;
    box-shadow: 0 2px 3px 0 rgba(0, 0, 0, .1);
}
nav a{
    font-size: 15px;
    text-transform: uppercase;
    color: white;
    text-decoration: none;
    line-height: 50px;
    position: relative;
    z-index: 1;
    display: inline-block;
    text-align: center;
}
nav .animation{
    position: absolute;
    /* 一种效果： */
    height: 100%;
    top: 0;

    /* 另一种效果： */
    /* height:5px;
    bottom: 0; */

    z-index: 0;
    background: #1abc9c;
    width: 100px;
    border-radius: 8px;
    transition: all .5s ease 0s;
}
a:nth-child(1){
    width: 100px;
}
nav a:nth-child(1):hover~.animation{
    width: 100px;
    left: 0;
}
a:nth-child(2){
    width: 100px;
}
nav a:nth-child(2):hover~.animation{
    width: 100px;
    left: 100px;
}
a:nth-child(3){
    width: 100px;
}
nav a:nth-child(3):hover~.animation{
    width: 100px;
    left: 200px;
}
a:nth-child(4){
    width: 100px;
}
nav a:nth-child(4):hover~.animation{
    width: 100px;
    left: 300px;
}
a:nth-child(5){
    width: 100px;
}
nav a:nth-child(5):hover~.animation{
    width: 100px;
    left: 400px;
}
